package com.briup.day09.todo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
class Person {
    private String name;
    // 人和交通工具的关系是什么？ 有、使用
    // 每一个人都可以选择一种交通工具
    private Transport transport;
    // 设定目的地
    private String target;

    public Person(String name, Transport transport, String target) {
        this.name = name;
        this.transport = transport;
        this.target = target;
    }

    public Person(String name, String transportName, String target) {
        this(name, new Transport(transportName), target);
    }

    // 执行任务
    public void doAction() {
        System.out.printf("%s%s去%s%n", name, transport.getName(), target);
    }
}

// 交通工具类
class Transport {
    private final String name;

    // 小汽车、公交车、双脚...
    public Transport(String name) {
        this.name = name;
    }

    public String getName() {
        return switch (name) {
            case "小汽车", "小车" -> "开车";
            case "双脚" -> "走路";
            case "公交车" -> "坐公交车";
            default -> "坐" + name;
        };
    }
}

class Test {
    public static void main(String[] args) {
        Person p = new Person("张三", "小汽车", "公司");
        Person p2 = new Person("李四", "飞机", "北京");
        Person p3 = new Person("王五", "双脚", "食堂");
        p.doAction();
        p2.doAction();
        p3.doAction();
    }
}
